<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="小区" prop="areaName">
        <el-select v-model="queryParams.areaName":filter-method="filterMethod" placeholder="请输入小区" filterable allow-create
                   clearable size="small"  default-first-option>
          <el-option v-for="(item, index) in areaIdOptions" :key="index" :label="item.areaName"
                     :value="item.areaName" :disabled="item.disabled" ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="开始时间" prop="startDate">
        <el-date-picker clearable size="small"
          v-model="queryParams.startDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="结束时间" prop="endDate">
        <el-date-picker clearable size="small"
          v-model="queryParams.endDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择结束时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          @click="handleExport"
        >导出</el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="moneyFlowList" >
      <el-table-column label="小区" align="center" prop="areaName" />
      <el-table-column label="收入户数" align="center" prop="shouSum" />
      <el-table-column label="收入金额" align="center" prop="shouMoney" />
      <el-table-column label="退款户数" align="center" prop="tuiSum" />
      <el-table-column label="退款金额" align="center" prop="tuiMoney"/>
      <el-table-column label="返回户数" align="center" prop="fanSum" />
      <el-table-column label="返回金额" align="center" prop="fanMoney" />
      <el-table-column label="维修户数" align="center" prop="paySum" />
      <el-table-column label="维修金额" align="center" prop="payMoney" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listMoneyFlow,getAreaInfo,getAreaInfo1} from "@/api/report/moneyFlow";

export default {
  name: "MoneyFlow",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 缴费信息表格数据
      moneyFlowList: [],
      areaIdOptions:[{}],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        houseId: null,
        areaName:null,
        costDate: null,
        costSts: null,
        costWay: null,
        checkSts: null,
        billNo: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
    this.filterMethod();
    this.areaSelect();
  },
  methods: {
    filterMethod(val){
      this.value=val
      getAreaInfo1(this.value).then(response => {
        this.areaIdOptions = response.rows;
      });
    },
    areaSelect(){
      getAreaInfo().then(response => {
        this.areaIdOptions = response.rows;
      });
    },
    /** 查询缴费信息列表 */
    getList() {
      this.loading = true;
      listMoneyFlow(this.queryParams).then(response => {
      debugger
        this.moneyFlowList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.areaSelect();
      this.handleQuery();
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('repoprt/moneyFlow/export', {
        ...this.queryParams
      }, `moneyFlow_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
